package org.yaac.shared;

/**
 * logical error codes
 * 
 * will be i18ned
 * 
 * syntax error will simply copy ANTLR's msg
 * 
 * @author Max Zhu (thebbsky@gmail.com)
 *
 */
public interface ErrorCode {

	// ===============================EGQL related========================
	/**
	 * ORA-00937: not a single-group group function
	 * 
	 * Cause:	
	 * 	A SELECT list cannot include both a group function, 
	 * 	such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, 
	 * 	and an individual column expression, 
	 * 	unless the individual column expression is included in a GROUP BY clause.
	 * 
	 * Action:	
	 * 	Drop either the group function or the individual column expression 
	 * 	from the SELECT list or add a GROUP BY clause 
	 * 	that includes all individual column expressions listed.
	 */
	public static final String E001 = "E001";
	
	/**
	 * ORA-00979: not a GROUP BY expression
	 * Cause:
	 * 	You tried to execute a SELECT statement that included a GROUP BY function (ie: MIN, MAX, SUM, COUNT) and 
	 * 	an expression in the SELECT / HAVING list that was not in the GROUP BY clause.
	 * 
	 * Action:
	 * The options to resolve this Oracle error are:
	 * 	Rewrite the SELECT / HAVING statement so that the column or expression listed in the SELECT / HAVING list is also found in the GROUP BY clause.
	 * 	Remove the GROUP BY function (ie: MIN, MAX, SUM, COUNT) from the SELECT statement.
	 * 	Remove the expression from the SELECT / HAVING list that was not in the GROUP BY clause.
	 * 
	 * Remarks:
	 * 	non aggregation conditions in having clause is valid!!! 
	 * 	However, all fields listed in having clause must be listed in group by clause (for aggregation query)
	 */
	public static final String E002 = "E002";
	
	/**
	 * ORA-00909: invalid number of arguments
	 */
	public static final String E003 = "E003";
	
	/**
	 * nested group function is not supported
	 */
	public static final String E004 = "E004";
	
	/**
	 * aggregation function can't be used together with select all (*)
	 */
	public static final String E005 = "E005";
	
	/**
	 * missing keyword from
	 * 
	 * @deprecated now we will throw ANTLR's exception directly
	 */
	@Deprecated
	public static final String E006 = "E006";
	
	/**
	 * duplicated insert items
	 */
	public static final String E050 = "E050";
	
	/**
	 * aggregation function is not allowed in insert statement
	 */
	public static final String E051 = "E051";
	
	/**
	 * field is not allowed in insert statement without select clause
	 * 
	 * @deprecated now fields are supported by insert statement
	 */
	@Deprecated
	public static final String E052 = "E052";
	
	/**
	 * invalid blobstore filter
	 */
	public static final String E201 = "E201";
	
	/**
	 * aggregation function is not allowed in datastore editor
	 */
	public static final String E301 = "E301";
	
	/**
	 * entity not found
	 */
	public static final String E302 = "E302";
	
	/**
	 * file not found 
	 */
	public static final String E303 = "E303";
	
	// ============================arithmetic operators========================
	/**
	 *  add can only happen between two decimals
	 */
	public static final String W001 = "W001";
	
	/**
	 *  subtract can only happen between two decimals
	 */
	public static final String W002 = "W002";
	
	/**
	 *  multiply can only happen between two decimals
	 */
	public static final String W003 = "W003";
	
	/**
	 *  divide can only happen between two decimals
	 */
	public static final String W004 = "W004";
	
	/**
	 *  can not divide by zero
	 *  
	 */
	public static final String W005 = "W005";

	/**
	 * % can only happen between two decimals
	 */
	public static final String W006 = "W006";
	
	/**
	 *  can not mod by zero
	 *  
	 */
	public static final String W007 = "W007";
	
	// ============================boolean operators========================
	/**
	 *  Not evaluator only works to boolean
	 *  
	 *  thrown by not evaluator
	 */
	public static final String W051 = "W051";
	
	/**
	 *  and can only happen between two booleans
	 *  
	 *  thrown by not evaluator
	 */
	public static final String W052 = "W052";
	
	/**
	 *  or can only happen between two booleans
	 *  
	 *  thrown by not evaluator
	 */
	public static final String W053 = "W053";
	
	// ============================scalar functions========================
	/**
	 * ucase function expects exact one argument
	 * 
	 * thrown by scalar function : ucase
	 */
	public static final String W101 = "W101";
	
	/**
	 * lcase function expects exact one argument
	 * 
	 * thrown by scalar function : lcase
	 */
	public static final String W102 = "W102";
	
	/**
	 * function ucase only take effect on string
	 * 
	 * thrown by scalar function : ucase
	 */
	public static final String W103 = "W103";
	
	/**
	 * function lcase only take effect on string
	 * 
	 * thrown by scalar function : lcase
	 */
	public static final String W104 = "W104";
	
	/**
	 * only number and date can be formatted
	 * 
	 * thrown by scalar function : format 
	 */
	public static final String W105 = "W105";
	
	/**
	 * 2nd argument of format function must be a string
	 * 
	 * thrown by scalar function : format 
	 */
	public static final String W106 = "W106";
	
	/**
	 * two arguments are required for format function
	 * 
	 * thrown by scalar function : format 
	 */
	@Deprecated
	public static final String W107 = "W107";
	
	/**
	 * function len only works to string / text / shortblob / blob / list
	 * 
	 * thrown by scalar function : len
	 */
	public static final String W108 = "W108";

	/**
	 * only one expression is allowed for len function
	 * 
	 * thrown by scalar function : len
	 */
	public static final String W109 = "W109";
	
	/**
	 * function mid only works with (string, number, [number]) arguments
	 * 
	 * thrown by scalar function : mid
	 */
	public static final String W110 = "W110";
	
	/**
	 * two or three expressions are required for mid function
	 * 
	 * thrown by scalar function : mid
	 */
	public static final String W111 = "W111";
	
	/**
	 * No argument is allowed for now function
	 * 
	 * thrown by scalar function : now
	 */
	@Deprecated
	public static final String W112 = "W112";
	
	/**
	 * function round only works to (number, number) input
	 * 
	 * thrown by scalar function : round
	 */
	public static final String W113 = "W113";
	
	/**
	 * two expressions are required for round function
	 * 
	 * thrown by scalar function : round
	 */
	public static final String W114 = "W114";
	
	/**
	 * one expression is allowed for type function
	 * 
	 * thrown by scalar function : type
	 */
	public static final String W115 = "W115";
	
	/**
	 * can not be parsed as default formats yyyyMMdd and yyyyMMddHHmmss
	 * 
	 * thrown by scalar function : datetime
	 */
	public static final String W116 = "W116";
	
	/**
	 * function datetime only works to (string, [string]) input
	 * 
	 * thrown by scalar function : datetime
	 */
	public static final String W117 = "W117";
	
	/**
	 * can not be parsed as user specified formats
	 * 
	 * thrown by scalar function : datetime
	 */
	public static final String W118 = "W118";
	
	/**
	 * two expressions are required for round function
	 * 
	 * thrown by scalar function : datetime
	 */
	public static final String W119 = "W119";
	
	/**
	 * one expression is required for user function
	 * 
	 * thrown by scalar function : user
	 */
	public static final String W120 = "W120";
	
	/**
	 * only string input is a valid input
	 * 
	 * thrown by scalar function : user
	 */
	public static final String W121 = "W121";
	
	/**
	 * two expressions are required for geopt function
	 * 
	 * thrown by scalar function : geopt
	 */
	public static final String W122 = "W122";
	
	/**
	 * only decimal input is a valid input for geopt function
	 * 
	 * thrown by scalar function : geopt
	 */
	public static final String W123 = "W123";
	
	/**
	 * at least one expression is required for key function
	 * 
	 * thrown by scalar function : key
	 */
	public static final String W124 = "W124";
	
	/**
	 * encoded key must be a string
	 * 
	 * thrown by scalar function : key
	 */
	public static final String W125 = "W125";
	
	/**
	 * kind must be a string
	 * 
	 * thrown by scalar function : key
	 */
	public static final String W126 = "W126";
	
	/**
	 * key name / id must be a string or a number
	 * 
	 * thrown by scalar function : key
	 */
	public static final String W127 = "W127";
	
	/**
	 * kind and ID/Name must go in pairs
	 * 
	 * thrown by scalar function : key
	 */
	public static final String W128 = "W128";
	
	/**
	 * invalid encoded key
	 * 
	 * thrown by scalar function : key
	 */
	public static final String W129 = "W129";
	
	/**
	 * only string input is valid for fucntion postaladdress 
	 * 
	 * thrown by scalar function : postaladdress
	 */
	public static final String W130 = "W130";

	/**
	 * shortblob
	 * 
	 * only string input is valid for function shortblob
	 */
	public static final String W131 = "W131";

	/**
	 * text
	 * 
	 * only string input is valid for function text
	 */
	public static final String W132 = "W132";

	/**
	 * phonenumber
	 * 
	 * only string input is valid for function phonenumber 
	 */
	public static final String W133 = "W133";

	/**
	 * category
	 * 
	 * only string input is valid for function category
	 */
	public static final String W134 = "W134";

	/**
	 * link
	 * 
	 * only string input is valid for function link
	 */
	public static final String W135 = "W135";

	/**
	 * email
	 * 
	 * only string input is valid for function email
	 */
	public static final String W136 = "W136";

	/**
	 * blob
	 * 
	 * only string input is valid for function blob
	 */
	public static final String W137 = "W137";

	/**
	 * long
	 * 
	 * only numeric input is valid for function long
	 */
	public static final String W138 = "W138";

	/**
	 * double
	 * 
	 * only numeric input is valid for function double
	 */
	public static final String W139 = "W139";

	/**
	 * blobkey
	 * 
	 * only string input is valid for function blobkey
	 */
	public static final String W140 = "W140";

	/**
	 * imhandle
	 * 
	 * only string input is valid for function imhandle
	 */
	public static final String W141 = "W141";

	/**
	 * imhandle
	 * 
	 * input protocol does not match enum Scheme
	 */
	public static final String W142 = "W142";
	
	/**
	 * geopt
	 * 
	 * Longitude must be between -180 and 180 and Latitude must be between -90 and 90 (inclusive).
	 */
	public static final String W143 = "W143";
	// TODO : aggregation functions
}
